﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data;
using KPIS.GERP.GHRMS.DAL;
using KPIS.GERP.GHRMS.MODEL;
using KPIS.GERP.GHRMS.IBLL;
using KPIS.GERP.GHRMS.IDAL;
using KPIS.GERP.GHRMS.DALFactory;

namespace KPIS.GERP.GHRMS.BLL
{
    public class RoyalItemControlBLL : IRoyalItemControlBLL
    {
        private static readonly IRoyalItemControlDAL DAL = DataAccess.CreateRoyalItemControls();

        private RoyalItemControlInfo ctrlInfo = new RoyalItemControlInfo();
        private EmployeeInfo empInfo = new EmployeeInfo();
        private RoyalItemInfo riInfo = new RoyalItemInfo();

        public IList<RoyalItemControlInfo> ListRoyalItemControls()
        {
            return DAL.ListRoyalItemControls(new RoyalItemControlInfo(0));
        }
        public IList<RoyalItemControlInfo> GridRoyalItemControls()
        {
            return DAL.GridRoyalItemControls(new RoyalItemControlInfo(0));
        }
        public void Insert(string Employee, string RoyalItems, DateTime GetDate, string Remarks, int CreatedBy)
        {
            if (Employee.Length > 0)
                empInfo.Sequence = Int32.Parse(Employee);
            if (RoyalItems.Length > 0)
                riInfo.Sequence = Int32.Parse(RoyalItems);

            try
            {
                DAL.Insert(new RoyalItemControlInfo(0, empInfo, riInfo, GetDate, (DateTime?)null, "", 0, Remarks
                    , "", CreatedBy, 0));
            }
            catch
            {
                throw new Exception("");
            }
        }
        public void Update(int Sequence, string Employee, string RoyalItems, DateTime GetDate, string Remarks, int UpdatedBy)
        {
            if (Employee.Length > 0)
                empInfo.Sequence = Int32.Parse(Employee);
            if (RoyalItems.Length > 0)
                riInfo.Sequence = Int32.Parse(RoyalItems);

            try
            {
                DAL.Update(new RoyalItemControlInfo(Sequence, empInfo, riInfo, GetDate, (DateTime?)null
                    , "", 0, Remarks, "", 0, UpdatedBy));
            }
            catch
            {
                throw new Exception("");
            }
        }
        public void UpdateReturn(int Sequence, DateTime ReturnDate, string ReturnFlag, double ReturnAmount, string Remarks, int UpdatedBy)
        {
            try
            {
                DAL.UpdateReturn(new RoyalItemControlInfo(Sequence, empInfo, riInfo, (DateTime?)null, ReturnDate, ReturnFlag
                    , ReturnAmount, Remarks, "", 0, UpdatedBy));
            }
            catch
            {
                throw new Exception("");
            }
        }
        public void Delete(int Sequence, int UpdatedBy)
        {
            try
            {
                DAL.Delete(Sequence, UpdatedBy);
            }
            catch
            {
                throw new Exception("");
            }
        }
    }
}
